# docker image build -f yapi.dockerfile -t yapi:1.0.0 --network ser_network1 .
# docker run -ti -p 9002:3000 --network ser_network1 -d yapi:1.0.0 /bin/bash

FROM debian:buster-20211011

#apt-get的加速镜像
RUN sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
RUN sed -i 's|security.debian.org/debian-security|mirrors.ustc.edu.cn/debian-security|g' /etc/apt/sources.list

#更新apt-get
RUN apt-get update

#复制文件
COPY ./file/* /usr/local/src/

# 安装node
RUN tar -zxvf /usr/local/src/node-v12.22.7-linux-x64.tar.gz -C /usr/local
ENV PATH /usr/local/node-v12.22.7-linux-x64/bin:$PATH

#安装
#RUN apt-get install -y git
RUN apt-get install -y unzip

RUN mkdir /yapi
#RUN git clone --depth=1 https://github.com/YMFE/yapi.git /yapi/vendors
RUN unzip /usr/local/src/yapi-master.zip -d /yapi  && mv /yapi/yapi-master /yapi/vendors

#RUN cp ./config/config.json /yapi/config.json
COPY ./config/config.json /yapi/config.json

RUN cd /yapi/vendors && rm -rf package-lock.json && npm install --production --registry https://registry.npm.taobao.org

# 初始化数据库
RUN cd /yapi/vendors && npm run install-server

EXPOSE 3000

#运行
ENTRYPOINT node /yapi/vendors/server/app.js